package org.example.infrastructure.persistence.remote.fallbackFactory;

import org.example.infrastructure.persistence.remote.RemoteUrlShortenerGroupPersistence;
import org.example.web.exception.ServerException;
import org.example.web.result.ResultInfo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
public class RemoteUrlShortenerGroupFallbackFactory implements FallbackFactory<RemoteUrlShortenerGroupPersistence> {
    private static final Logger log = LoggerFactory.getLogger(RemoteUrlShortenerGroupFallbackFactory.class);

    @Override
    public RemoteUrlShortenerGroupPersistence create(Throwable cause) {

        return new RemoteUrlShortenerGroupPersistence() {
            @Override
            public ResultInfo<List<String>> selectGitListByUserName(String userName) {
                log.error("获取分组gid失败");
                throw new ServerException("获取分组gid失败！");
            }
        };
    }
}
